package com.midou.administration.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.midou.administration.bo.AppointmentBo;
import com.midou.administration.bo.AppointmentBob;
import com.midou.administration.bo.AppointmentBoquxiao;
import com.midou.administration.bo.ZhuohaoBo;
import com.midou.administration.entity.Appointment;
import com.midou.administration.entity.Desk;
import com.midou.administration.entity.DeskType;
import com.midou.administration.mapper.DeskMapper;
import com.midou.administration.service.impl.AppointmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/administration/appointment")
public class AppointmentController {
    @Autowired
    private AppointmentService appointmentService;
    @Autowired
    private DeskMapper deskMapper;
    @RequestMapping("zhuotai")
    public List<DeskType> queryZhuotai(@RequestBody Integer id){
        List<DeskType> list=appointmentService.ZtAll(id);
        return appointmentService.ZtAll(id);
    }

    @RequestMapping("queryAdd")
    public int queryAdd(@RequestBody Appointment appointment){
        int c=appointmentService.queryAdd(appointment);
        return c;
    }
    @RequestMapping("querySelect")
    public Page querySelect(@RequestBody AppointmentBob appointmentBob){
        Page list=appointmentService.querySelect(appointmentBob);
        return list;
    }

    @RequestMapping("queryDelete")
    public int queryDelete(@RequestBody AppointmentBoquxiao appointmentBoquxiao){
        int c=appointmentService.queryDelete(appointmentBoquxiao.getPhone());
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("desk_id",appointmentBoquxiao.getDeskId());
        Desk desk=deskMapper.selectOne(queryWrapper);
        int d=deskMapper.queryQuxiao(desk);
        return appointmentService.queryDelete(appointmentBoquxiao.getPhone());
    }

    @RequestMapping("queryZhuoh")
    public List<Desk> queryZhuoh(@RequestBody ZhuohaoBo zhuohaoBo){
        List<Desk> list=appointmentService.queryZhuoh(zhuohaoBo);
        return appointmentService.queryZhuoh(zhuohaoBo);
    }
}
